package com.cgbl.service.adapter

import androidx.appcompat.widget.AppCompatImageView
import com.cgbl.service.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class FilterAdapter(var select: String) :
    BaseQuickAdapter<String, BaseViewHolder>(R.layout.app_item_filter) {
    override fun convert(holder: BaseViewHolder, item: String) {
        val ivSelect = holder.getView<AppCompatImageView>(R.id.item_iv_select)
        ivSelect.isSelected = item == select
        holder.setText(R.id.item_tv_name, item)

        holder.itemView.setOnClickListener {
            if(getOnItemClickListener()!=null){
                getOnItemClickListener()?.onItemClick(this, it, holder.adapterPosition)
            }
            select = item
            notifyDataSetChanged()
        }
    }
}